package com.ruoyi.web.controller.wbgame;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.wbgame.domain.WbGameCreate;
import com.ruoyi.wbgame.service.IWbGameCreateService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 游戏创建Controller
 * 
 * @author guguofu
 * @date 2021-04-16
 */
@Controller
@RequestMapping("/wbgame/gameCreate")
public class WbGameCreateController extends BaseController
{
    private String prefix = "wbgame/gameCreate";

    @Autowired
    private IWbGameCreateService wbGameCreateService;

    @RequiresPermissions("wbgame:gameCreate:view")
    @GetMapping()
    public String gameCreate()
    {
        return prefix + "/gameCreate";
    }

    /**
     * 查询游戏创建列表
     */
    @RequiresPermissions("wbgame:gameCreate:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(WbGameCreate wbGameCreate)
    {
        startPage();
        List<WbGameCreate> list = wbGameCreateService.selectWbGameCreateList(wbGameCreate);
        return getDataTable(list);
    }

    /**
     * 导出游戏创建列表
     */
    @RequiresPermissions("wbgame:gameCreate:export")
    @Log(title = "游戏创建", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WbGameCreate wbGameCreate)
    {
        List<WbGameCreate> list = wbGameCreateService.selectWbGameCreateList(wbGameCreate);
        ExcelUtil<WbGameCreate> util = new ExcelUtil<WbGameCreate>(WbGameCreate.class);
        return util.exportExcel(list, "gameCreate");
    }

    /**
     * 新增游戏创建
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存游戏创建
     */
    @RequiresPermissions("wbgame:gameCreate:add")
    @Log(title = "游戏创建", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(WbGameCreate wbGameCreate)
    {
        return toAjax(wbGameCreateService.insertWbGameCreate(wbGameCreate));
    }

    /**
     * 修改游戏创建
     */
    @GetMapping("/edit/{teacherId}")
    public String edit(@PathVariable("teacherId") Long teacherId, ModelMap mmap)
    {
        WbGameCreate wbGameCreate = wbGameCreateService.selectWbGameCreateById(teacherId);
        mmap.put("wbGameCreate", wbGameCreate);
        return prefix + "/edit";
    }

    /**
     * 修改保存游戏创建
     */
    @RequiresPermissions("wbgame:gameCreate:edit")
    @Log(title = "游戏创建", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(WbGameCreate wbGameCreate)
    {
        return toAjax(wbGameCreateService.updateWbGameCreate(wbGameCreate));
    }

    /**
     * 删除游戏创建
     */
    @RequiresPermissions("wbgame:gameCreate:remove")
    @Log(title = "游戏创建", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(wbGameCreateService.deleteWbGameCreateByIds(ids));
    }
}
